/**
 * 
 */

function getId(id) {
	return document.getElementById(id);
}

var url = "index.jsp?inc_contents=./board/";

function board_init() {
	if (getId("brd_btnList") != null) {
		getId("brd_btnList").onclick = function() {
			location.href = url + "list.jsp";
		};
	}
	if (getId("brd_btnSave") != null) {
		getId("brd_btnSave").onclick = function() {
			if(frm_save.subject.value==""||frm_save.pwd.value==""||frm_save.content.value==""){
				alert("모든칸을 채워주세요");
				return;
			}else{
				frm_save.action = url + "register_result.jsp";
				frm_save.submit();
			}
			
		};
	}
	if (getId("brd_btnModify") != null) {
		getId("brd_btnModify").onclick = function() {
			if(frm_modify.subject.value==""||frm_modify.pwd.value==""||frm_modify.content.value==""){
				alert("모든칸을 채워주세요");
				return;
			}else{
				frm_modify.action = url + "modify_result.jsp";
				frm_modify.submit();
			}
		};
	}
	if (getId("brd_btnRepResult") != null) {
		getId("brd_btnRepResult").onclick = function() {
			if(frm_rep.subject.value==""||frm_rep.pwd.value==""||frm_rep.content.value==""){
				alert("모든칸을 채워주세요");
				return;
			}else{
				frm_rep.action = url + "rep_register_result.jsp";
				frm_rep.submit();
			}
		};
	}
	if (getId("brd_btnFind") != null) {
		getId("brd_btnFind").onclick = function() {
			board_frm.action =  url + "list.jsp";
			board_frm.submit();
			
		};
	}
	if (getId("brd_btnComment") != null) {
		getId("brd_btnComment").onclick = function() {
			if(frm_comment.content.value==""){
				alert("내용을 입력해 주세요");
				return;
			}else{
				frm_comment.action = url + "comen_result.jsp";
				frm_comment.submit();
			}
		};
	}

}
function brd_input() {
	location.href = url + "register.jsp";
}

function brd_mod(serial) {
	location.href = url + "modify.jsp&serial=" + serial;
}
function brd_del(serial, pwd, filename) {
	var f = prompt("암호를 입력해주세요.");
	if(pwd==f){
		location.href = url + "delete_result.jsp&serial=" + serial
		+ "&filename=" + filename;
	}else{
		alert("암호가 일치하지 않습니다");
	}
}
function brd_rep(serial, grp, deep) {
	location.href = url + "rep_register.jsp&serial=" + serial + "&grp=" + grp
			+ "&deep=" + deep;
}
/*function list() {
	location.href = url + "list.jsp";
}*/

function goBoard(part) {
	location.href = url + "list.jsp&part=" + part;
}

// 파일 다운로드 스크립트
// 새창을 열어 첨부파일을 무조건 다운로드하도록 조치
function fileDownLoad(filename) {
	data = './board/filedownload.jsp?filename=' + filename;
	win = window.open(data, "win", "");
}

function fileDel(fileDelFlag, serial) {
	location.href = url + 'modify.jsp&fileDelFlag=' + fileDelFlag + "&serial="
			+ serial;

}

function goPage(page){
	var ff = document.board_frm;
	
	ff.nowPage.value = page;
	ff.action =  url + "list.jsp";
	ff.submit();
}
